package com.tutu.carousel.controller;

import cn.hutool.core.collection.CollUtil;
import com.tutu.carousel.service.CarouselService;
import com.tutu.commons.pojo.Carousel;
import com.tutu.commons.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Program: b2c-cloud-store
 * @Description:
 * @Author: JK.TuTu
 * @ @Version: 1.0
 * @Create: 2022-12-14 17:07
 **/
@Slf4j
@RestController
@RequestMapping("carousel")
@Api("前台首页轮播图相关api")
public class CarouselController {

    @Autowired
    private CarouselService carouselService;

    /**
     * 获取轮播图信息
     * @return 返回结果实体 对象
     */
    @GetMapping("list")
    @ApiOperation("获取轮播图信息")
    public R getCarousel(){
        List<Carousel> carouselList = carouselService.getCarousel();
        if(CollUtil.isEmpty(carouselList)){
            return R.fail("获取轮播图失败!");
        }
        return R.ok(carouselList);
    }


}
